package com.ruoyi.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Jfdhsz;
import com.ruoyi.system.service.IJfdhszService;
import com.ruoyi.framework.web.base.BaseController;
import com.ruoyi.common.page.TableDataInfo;
import com.ruoyi.common.base.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 积分兑换设置 信息操作处理
 * 
 * @author ruoyi
 * @date 2019-07-16
 */
@Controller
@RequestMapping("/system/jfdhsz")
public class JfdhszController extends BaseController
{
    private String prefix = "system/jfdhsz";
	
	@Autowired
	private IJfdhszService jfdhszService;
	
	@RequiresPermissions("system:jfdhsz:view")
	@GetMapping()
	public String jfdhsz()
	{
	    return prefix + "/jfdhsz";
	}
	
	/**
	 * 查询积分兑换设置列表
	 */
	@RequiresPermissions("system:jfdhsz:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(Jfdhsz jfdhsz)
	{
		startPage();
        List<Jfdhsz> list = jfdhszService.selectJfdhszList(jfdhsz);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出积分兑换设置列表
	 */
	@RequiresPermissions("system:jfdhsz:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(Jfdhsz jfdhsz)
    {
    	List<Jfdhsz> list = jfdhszService.selectJfdhszList(jfdhsz);
        ExcelUtil<Jfdhsz> util = new ExcelUtil<Jfdhsz>(Jfdhsz.class);
        return util.exportExcel(list, "jfdhsz");
    }
	
	/**
	 * 新增积分兑换设置
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存积分兑换设置
	 */
	@RequiresPermissions("system:jfdhsz:add")
	@Log(title = "积分兑换设置", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(Jfdhsz jfdhsz)
	{		
		return toAjax(jfdhszService.insertJfdhsz(jfdhsz));
	}

	/**
	 * 修改积分兑换设置
	 */
	@GetMapping("/edit/{jfdhszId}")
	public String edit(@PathVariable("jfdhszId") Integer jfdhszId, ModelMap mmap)
	{
		Jfdhsz jfdhsz = jfdhszService.selectJfdhszById(jfdhszId);
		mmap.put("jfdhsz", jfdhsz);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存积分兑换设置
	 */
	@RequiresPermissions("system:jfdhsz:edit")
	@Log(title = "积分兑换设置", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(Jfdhsz jfdhsz)
	{		
		return toAjax(jfdhszService.updateJfdhsz(jfdhsz));
	}
	
	/**
	 * 删除积分兑换设置
	 */
	@RequiresPermissions("system:jfdhsz:remove")
	@Log(title = "积分兑换设置", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(jfdhszService.deleteJfdhszByIds(ids));
	}

	/**
	 * 修改积分兑换设置状态
	 * @param jfdhsz
	 * @return
	 */
	@Log(title = "积分兑换设置", businessType = BusinessType.UPDATE)
	@RequiresPermissions("system:jfdhsz:edit")
	@PostMapping("/changeStatus")
	@ResponseBody
	public AjaxResult changeStatus(Jfdhsz jfdhsz){
		return toAjax(jfdhszService.updateJfdhsz(jfdhsz));
	}
}
